package jtk.project4.fleet.field;

/*
* Author : Rio Dermawan 
* Date Created : 1-April-2011
* Date Modified : 6-April-2011
* Version : 1.1
* */

//import jtk.project4.fleet.domain.Customer;
import java.awt.FlowLayout;

import jtk.project4.fleet.action.AddCustomerAction;
import jtk.project4.fleet.domain.Customers;

import nl.coderight.jazz.action.Action;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.TableField;
import nl.coderight.jazz.form.field.TableField.AutoResizeMode;
import nl.coderight.jazz.form.field.button.PushButton;

public class CustomerManagementField extends GroupControl {
	private TableField<Customers> customerTable; 
	private Action addCustomer;
	
	public CustomerManagementField  (String bindID){
		setTitle("header.identification"); 
		setBindID(bindID);
		addCustomer = new AddCustomerAction();
		createFields();
		createLayout();
	}
	
	private void createFields(){
		//setup table
		customerTable = new TableField<Customers> ("customers", "customer");
		customerTable.setTitle("customers.header.table");
		customerTable.setAutoResizeMode(AutoResizeMode.OFF);
		customerTable.getSelectionValues();

		//setup column
		//customerTable.addColumn("Vendor ID","vendorId");
		customerTable.addColumn("Name","name");
		customerTable.addColumn("Contact","contact");
		customerTable.addColumn("Address1","address1");
		customerTable.addColumn("Address2","address2");
		customerTable.addColumn("City","city");
		customerTable.addColumn("State_","state");
		customerTable.addColumn("Zip","zip");
		customerTable.addColumn("Country","country");
		customerTable.addColumn("Phone1","phone1");
		customerTable.addColumn("Phone2","phone2");
		customerTable.addColumn("Fax","fax");
		customerTable.addColumn("Email","email");
		customerTable.addColumn("Comments","comments");
		customerTable.addColumn("Type_","type");
		customerTable.addColumn("Terms","terms");
		customerTable.addColumn("Website","website");
		
		/*customerTable.addColumn("label.address1","Address1");
		customerTable.addColumn("label.address2","Address2");
		customerTable.addColumn("label.city","City");
		customerTable.addColumn("label.state","State/Province");
		customerTable.addColumn("label.postal","Postal Code");
		customerTable.addColumn("label.country","Country");
		customerTable.addColumn("label.phone1","Phone #1");
		customerTable.addColumn("label.phone2","Phone #2");
		customerTable.addColumn("label.fax","Fax");
		customerTable.addColumn("label.email","E-mail");
		customerTable.addColumn("label.website","Website");
		customerTable.addColumn("label.term","Term");
		customerTable.addColumn("label.location","Location");
		customerTable.addColumn("label.comments","Comments");*/
	}
	
	/*private void createLayout(){
		addField(customerTable);
		
		
	}*/
	
	private void createLayout() {
		// TODO Auto-generated method stub
		addField(createFieldGroup(),CENTER);
		addField(createButtons(),SOUTH);
	}
	
	
	private GroupControl createFieldGroup(){
		GroupControl fieldGroup=new GroupControl();
		fieldGroup.addField(customerTable,CENTER);
		//fieldGroup.addField(new PushButton("add"), );
		return fieldGroup;
	}
	
	private GroupControl createButtons() {
		GroupControl buttons = new GroupControl();
		buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
		buttons.addField(new PushButton(addCustomer), SOUTH);
		return buttons;
	}
}
